import 'package:backend.core/core/domain/entities/google_play/google_play_purchased_subscription_info_cancellation_survey_result.dart';
import 'package:backend.purchases/domain/entities/google_play_api/google_play_api_purchased_subscription_cancellation_survey_result.dart';
import 'package:backend.purchases/domain/helpers/google_play/create_google_play_purchased_subscription_info_cancellation_survey_reason_from_api_one.dart';

abstract class CreateGooglePlayPurchasedSubscriptionInfoCancellationSurveyResultFromApiOne {
  GooglePlayPurchasedSubscriptionInfoCancellationSurveyResult call({
    required GooglePlayApiPurchasedSubscriptionCancellationSurveyResult apiSurveyResult,
  });
}

class CreateGooglePlayPurchasedSubscriptionInfoCancellationSurveyResultFromApiOneImpl
    implements CreateGooglePlayPurchasedSubscriptionInfoCancellationSurveyResultFromApiOne {
  const CreateGooglePlayPurchasedSubscriptionInfoCancellationSurveyResultFromApiOneImpl({
    required CreateGooglePlayPurchasedSubscriptionInfoCancellationSurveyReasonFromApiOne
        createGooglePlayPurchasedSubscriptionInfoCancellationSurveyReasonFromApiOne,
  }) : _createGooglePlayPurchasedSubscriptionInfoCancellationSurveyReasonFromApiOne =
            createGooglePlayPurchasedSubscriptionInfoCancellationSurveyReasonFromApiOne;

  final CreateGooglePlayPurchasedSubscriptionInfoCancellationSurveyReasonFromApiOne
      _createGooglePlayPurchasedSubscriptionInfoCancellationSurveyReasonFromApiOne;

  @override
  GooglePlayPurchasedSubscriptionInfoCancellationSurveyResult call({
    required GooglePlayApiPurchasedSubscriptionCancellationSurveyResult apiSurveyResult,
  }) {
    final reason = _createGooglePlayPurchasedSubscriptionInfoCancellationSurveyReasonFromApiOne(
      apiSurveyReason: apiSurveyResult.reason,
    );

    return GooglePlayPurchasedSubscriptionInfoCancellationSurveyResult(
      reason: reason,
      customAnswer: apiSurveyResult.customAnswer,
    );
  }
}
